package com.dsa.utils;

import java.util.Arrays;
import java.util.Random;
import java.util.stream.IntStream;

public class ArrayGenerator {

    private static final Random RANDOM = new Random();

    private ArrayGenerator() {}

    public static Integer[] sequencingArray(int n) {
        return IntStream.range(0, n).boxed()
                .toArray(Integer[]::new);
    }

    public static Integer[] randomArray(int n, int bound) {
        return IntStream.range(0, n).boxed()
                .map(v -> RANDOM.nextInt(bound))
                .toArray(Integer[]::new);
    }

    public static Integer[] sameArray(int n, int value) {
        Integer[] ints = new Integer[n];
        Arrays.fill(ints, value);
        return ints;
    }

    public static Integer[] copyArray(Integer[] src) {
        return Arrays.copyOf(src, src.length);
    }

    public static Integer[] copyOfRange(Integer[] src, int from, int to) {
        return Arrays.copyOfRange(src, from, to);
    }
}
